<template>
	<view class="container">
		<!-- 顶部导航栏 -->
		<u-navbar title="合同签署" :autoBack="true" :fixed="true" :bgColor="'#ffffff'" :placeholder="true" :titleStyle="{
				color: '#333',
				fontSize: '16px',
			}">
		</u-navbar>

		<!-- PDF预览区域 -->
		<!-- <web-view :src="pdfUrl"></web-view> -->
		<iframe :src="pdfUrl" frameborder="0" class="pdf-iframe"></iframe>
		<!-- 底部按钮 -->
		<!-- <view class="bottom-btn" @click="handleSign">确认并签署</view>
		<jp-signature-popup ref="signature2" v-model="image" popup />
		<image :src="image" style="width: 200px" mode="widthFix"></image> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pdfUrl: "", // 替换为实际的PDF文件URL
				canvasHeight: 400,
				canvasWidth: 400,
				width: 80,
				height: 50,
				left: 20,
				top: 20,
				ctx: null,
				image: "",
				imgs: "http://mmbiz.qpic.cn/sz_mmbiz_jpg/GEWVeJPFkSGTfkSpSbg9cHUqcibBv38r8GXDIVy4W6FN7a1TMWf6RSNQLemKBwG8VqjlxUhicIzz3NTONVrD96ibg/0?wx_fmt=jpeg",
			};
		},
		onLoad(e) {
			console.log(e)
			this.pdfUrl = this.$Config.HTTP_IMG_URL + '/third' + JSON.parse(e.info).attachment
			console.log(this.pdfUrl)
		},
		mounted() {
			//初始化画布
			// this.ctx = wx.createCanvasContext("shareCanvas", this);
			// uni.downloadFile({
			// 	url: this.pdfUrl,
			// 	success: function(res) {
			// 		console.log(res)
			// 		var filePath = res.tempFilePath;
			// 		uni.openDocument({
			// 			filePath: filePath,
			// 			showMenu: true,
			// 			success: function(res) {
			// 				console.log('打开文档成功');
			// 			}
			// 		});
			// 	}
			// });
		},
		methods: {
			handleSign() {
				// 处理签署逻辑
				this.$refs.signature2.toPop();
			},
		},
	};
</script>

<style lang="less" scoped>
	.container {
		box-sizing: border-box;
		height: 100vh;
		background: #f5f6fa;
		display: flex;
		padding: 0 24rpx env(safe-area-inset-bottom);
		flex-direction: column;
	}

	.pdf-iframe {
		width: 100%;
		height: calc(100% - 240rpx);
	}

	.bottom-btn {
		height: 88rpx;
		line-height: 88rpx;
		text-align: center;
		background: #2979ff;
		border-radius: 44rpx;
		color: #fff;
		font-size: 32rpx;
	}
</style>